<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tlds/struts-menu.tld" prefix="menu" %>
<%@ taglib uri="/WEB-INF/tlds/struts-menu-el.tld" prefix="menu-el" %>
<%@ taglib uri="/WEB-INF/tlds/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tlds/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tlds/authz.tld" prefix="authz" %>
<%@ taglib uri="/WEB-INF/tlds/sitemesh-decorator.tld" prefix="decorator"%>
<script type="text/javascript">
		var uid=0;
		var id=-1;
		a = new dTree('a');
		a.config.folderLinks=true;
		a.config.useIcons=false;
		a.config.useStatusText=true;
		a.config.useCookies=false;
		a.add(uid,-1,'o=canam','javascript:getChildren('+uid+');');
		function getChildren(aId) {
			id=aId;
			var e = a.aNodes[id];
			var res = e.name;
			while (e.pid != -1) {
				e = a.aNodes[e.pid];
				res += ',' + e.name;
			}
			document.getElementById('filterDiv').innerHTML='<p>Filtre: '+res+'</p>';
			document.getElementById('filter').value=res;
			LdapBrowser.getChildren(res,result);
		}
		function result(l) {
			var i;
			for(i=0;i<l.length;i++) {
			  uid++;
			  a.add(uid,id,l[i],'javascript:getChildren('+uid+');');
			}
			document.getElementById('tree').innerHTML=a.toString();
		}
	function validateTree() {
		var value = $F("filter");
		this.opener.document.getElementById('resource.baseDn').value=value;
		this.opener.document.getElementById('resource.baseDn').focus();
		closePopup();
	}
</script>
<div id="subcontent">
	<div class="item" id="tree">
	<script>
		document.write(a);
	</script>
	</div>
	<div id="filterDiv"></div>
 	<input type="hidden" name="filter" id="filter" value="o=canam"/>
	<p><input name="validateTreeButton" type="button" onclick="validateTree();return false;" value="Valider"/>&nbsp;<input name="cancelTreeButton" type="button" onclick="closePopup();" value="Annuler"/></p>
</div>
